//Get 80 score and this is a bad design! F**K!!!
#include<bits/stdc++.h>
#include<stdio.h>

#ifndef DEBUG
#define NDEBUG
#endif

#include<assert.h>

using namespace std;

struct ip_prefix_t{
    unsigned char addr[4]={0,0,0,0};
    int len = 0;
};

bool cmp(const ip_prefix_t &x,const ip_prefix_t &y){
        bool res;
        for(int i=0;i<4;i++){
            if(x.addr[i] < y.addr[i])
                return true;
            else if(x.addr[i] > y.addr[i])
                return false;
        }
        return x.len < y.len;
    }

void prefix_str2int(const string &prefix_str, ip_prefix_t &prefix){
    int si = prefix_str.find('/');
            
    int li=0, ci=0, i=0;
    
    ci = prefix_str.find('.', li);   
    while(ci != -1){        
        prefix.addr[i++]=stoi(prefix_str.substr(li,ci-li));        
        li = ci+1;
        ci = prefix_str.find('.', li); 
    }
    
    prefix.addr[i++] = stoi(prefix_str.substr(li));
    prefix.len = si != -1?stoi(prefix_str.substr(si+1)): (i << 3);
}
inline int caculate_xor_len(const bitset<32> &ip_xor, const int &a_len){
    int xor_len=0;
     while(xor_len < a_len && !ip_xor.test(31 - xor_len)){
        xor_len++;
    }
    return xor_len;
}

inline bool a_subset_b(const ip_prefix_t &a, const ip_prefix_t &b){
    if(a.len >= b.len)
        return false;
    bitset<32> ip_a(bitset<32>(a.addr[0]) << 24 | bitset<32>(a.addr[1] << 16) | bitset<32>(a.addr[2] << 8) | bitset<32>(a.addr[3]));
    bitset<32> ip_b(bitset<32>(b.addr[0]) << 24 | bitset<32>(b.addr[1] << 16) | bitset<32>(b.addr[2] << 8) | bitset<32>(b.addr[3]));
    bitset<32> ip_xor = ip_a ^ ip_b;    
    
    int xor_len = caculate_xor_len(ip_xor,a.len);
    #ifdef DEBUG
    cout << xor_len << endl;
    cout << ip_a << endl;
    cout << ip_b << endl;
    cout << ip_xor << endl;    
    #endif

    return xor_len == a.len;
}

inline void merge_s2l(list<ip_prefix_t> &prefixes){//s--small, 2--to, l--large
    auto it2 = prefixes.begin();
    list<ip_prefix_t>::iterator it1 = it2;    
    
    for(it1,++it2;it2 != prefixes.end();++it1, ++it2){
        //it1是it2的子集
        if(a_subset_b(*it1, *it2)){
            it2 = prefixes.erase(it2);
            it2--;
            it1--;
        }
    }

}

/**
 * return 0: don't erase ; return 1:erase a; return 2: erase b;
 * 
 * 
 **/
inline bool can_merge_s( ip_prefix_t &a, ip_prefix_t &b){//s--same    
    if(a.len != b.len)
        return false;
    if(a.addr[0] == b.addr[0] && a.addr[1] == b.addr[1] && a.addr[2] == b.addr[2] && a.addr[3] == b.addr[3])
        return true;
    
    bitset<32> ip_a(bitset<32>(a.addr[0]) << 24 | bitset<32>(a.addr[1] << 16) | bitset<32>(a.addr[2] << 8) | bitset<32>(a.addr[3]));
    bitset<32> ip_b(bitset<32>(b.addr[0]) << 24 | bitset<32>(b.addr[1] << 16) | bitset<32>(b.addr[2] << 8) | bitset<32>(b.addr[3]));
    bitset<32> ip_xor = ip_a ^ ip_b;
    int xor_len = caculate_xor_len(ip_xor,a.len);

    #ifdef DEBUG
    cout << xor_len << endl;
    cout << ip_a << endl;
    cout << ip_b << endl;
    cout << ip_xor << endl;    
    #endif

    if(xor_len + 1 == a.len){        
        int s=(a.len-1)/8;
        a.addr[s] &= b.addr[s];        
        a.len--;
        return true;
    }else{
        return false;
    }

}

inline void merge_same_level(list<ip_prefix_t> &prefixes){
    auto it1 = prefixes.begin(), it2 = it1;
    
    for(it1,++it2;it2 != prefixes.end();++it1, ++it2){
        if(can_merge_s(*it1,*it2)){
            it2 = prefixes.erase(it2);           
            if(it1 != prefixes.begin()){
                it1--;
                it2--;
            }
            it1--;
            it2--;
        }
    }
}

int main(){
    long long n=0;
    cin >> n;
    
    list<ip_prefix_t> prefixes(n);
    for(auto &prefix:prefixes){
        string line;
        cin >> line;
        prefix_str2int(line, prefix);
    }

    prefixes.sort(cmp);
    
    merge_s2l(prefixes);
    merge_same_level(prefixes);

    for(const auto &prefix:prefixes){
        printf("%d.%d.%d.%d/%d\n",prefix.addr[0],prefix.addr[1],prefix.addr[2],prefix.addr[3],prefix.len);
    }

    return 0;

}